﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using EC_Agent.AgentClass;
using System.Data;

namespace EC_Agent.Models
{
    public class LoaiDVModels
    {
        public DataSet ListLoaiDV()
        {
            DataService ds = new DataService();
            return ds.ShowData("ListLoaiDV");
        }

        public int InsertLoaiDV(LoaiDVInfo loaidv)
        {
            SqlParameter[] parameters = new SqlParameter[1];
            parameters[0] = new SqlParameter("@TenLoaiDV", loaidv.TenLoaiDV);
            DataService ds = new DataService();
            ds.Connect();
            ds.ExcuteProcedure("InsertLoaiDV", parameters);
            ds.Disconnect();
            return 1;        
            
        }

        public int UpdateLoaiDV(LoaiDVInfo loaidv)
        {
            SqlParameter[] parameters = new SqlParameter[2];
            parameters[0] = new SqlParameter("@MaLoaiDV", loaidv.MaLoaiDV);
            parameters[1] = new SqlParameter("@TenLoaiDV", loaidv.TenLoaiDV);
            DataService ds = new DataService();
            ds.Connect();
            ds.ExcuteProcedure("UpdateLoaiDV", parameters);
            ds.Disconnect();
            return 1;

        }

        public int DeleteLoaiDV(LoaiDVInfo loaidv)
        {
            SqlParameter[] parameters = new SqlParameter[1];
            parameters[0] = new SqlParameter("@MaLoaiDV", loaidv.MaLoaiDV);
            DataService ds = new DataService();
            ds.Connect();
            ds.ExcuteProcedure("DeleteLoaiDV", parameters);
            ds.Disconnect();
            return 1;

        }
    }
}